package com.kingdee.pda.ui.dialog;

import android.content.Context;
import android.content.DialogInterface;
import android.support.v7.app.AlertDialog;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;

import com.kingdee.pda.R;
import com.kingdee.pda.adapter.ReplenishUpdateNumAdapter;
import com.kingdee.pda.entity.ReplenishSkuBean;

import java.util.List;


/**
 * 补货修改已补数量弹框
 * 带有按钮回调的对话框
 */

public class ReplenishUpdateNumDialog {

    /**
     * @param activity
     * @param listener
     */
    public static void showUpdateNumDialog(List<ReplenishSkuBean.ActulBean> list, final Context activity, final InputListener listener) {
        View view = LayoutInflater.from(activity).inflate(R.layout.layout_replenish_skulist, null);
        RecyclerView recyclerView = view.findViewById(R.id.recyclerView);
        recyclerView.setLayoutManager(new LinearLayoutManager(activity));
        ReplenishUpdateNumAdapter adapter = new ReplenishUpdateNumAdapter(activity, list);
        recyclerView.setAdapter(adapter);
        AlertDialog.Builder builder = new AlertDialog.Builder(activity, R.style.base_common_AlertDialogStyle);
        builder.setView(view);
        builder.setCancelable(false);
        builder.setNegativeButton("取消", new DialogInterface.OnClickListener() {
            @Override
            public void onClick(DialogInterface dialog, int which) {

            }
        });
        builder.setPositiveButton("确定", null);
        AlertDialog alertDialog = builder.create();
        alertDialog.show();
        alertDialog.getButton(AlertDialog.BUTTON_POSITIVE).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                listener.okEvent(alertDialog);
            }
        });
    }

    public interface InputListener {
        void okEvent(DialogInterface dialog);
    }
}
